<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<link href="<s:url value="/css/style.css"/>" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript"
			src="<s:url value="/js/jquery-1.3.2.min.js"/>"></script>
		<script type="text/javascript" src="<s:url value="/js/common.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.bgiframe.min.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.ajaxQueue.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/thickbox-compressed.js"/>"></script>
		<script type='text/javascript'
			src="<s:url value="/js/autocomplete/jquery.autocomplete.js"/>"></script>
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/autocomplete/jquery.autocomplete.css"/>" />
		<script type="text/javascript" src="<s:url value="/js/jquery-ui.js"/>"></script>
		<script type="text/javascript"
			src="<s:url value="/js/jquery.blockUI.js"/>"></script>
		<link rel="stylesheet" type="text/css"
			href="<s:url value="/js/autocomplete/thickbox.css"/>" />
		<link href="<s:url value="/css/jquery.css"/>" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript" src="<s:url value="/js/jquery.validate.js"/>"></script>
		<script type="text/javascript">
		  $(document).ready(function(){
		          $('#editForm').validate();
		          if($.trim($('#result').text())!=''){
		                popupDiv('pop-div');
	               };
				  $("#selAdChannel").autocomplete("<s:url value="/data/AdChannel/autoCompleteAjax.action"/>", {
		              width: 300,
		              minChars:2, //几个字
		              mastMatch:true,
		              selectFirst: false,
		              max:  20,
		           	  formatItem: function(row, i, max) {
		           	      //alert(row);
		           	      var d=eval("("+row+")");
		           	      //alert(d);
					      return   d.name+" "+ d.pyname ;
			         },
				     formatMatch: function(row, i, max) {
				         var d=eval("("+row+")");
		 			     return  d.name+" "+ d.pyname ;
				     },
				     formatResult: function(row) {
				        // alert(row);
				         var d=eval("("+row+")");
					     return d.name;
		     	      }
		           });
		           $("#selAdChannel").result(function(event, data, formatted) {
		           	      var d=eval("("+data+")");
				          $("#selAdChannelId").val(d.id);
				          doSelectAdChannel(d.id);
		           });
		      
	               $('#startDate').datepicker({dateFormat:'yy-mm-dd'});
		           $('#endDate').datepicker({dateFormat:'yy-mm-dd'});
		           
            });
            function doSelectAdChannel(Eid){
                //alert($('#id').val());
				$('#id').val("");
				var t=$('#editForm');
                t.attr('action','edit');
				$('#editForm').submit();
		    };
            function doSave(){
                if (!$("#selAdChannelId").val()){
                   alert("please select a adchannel");
                   return false;
                }
                if (!$("#startDate").val()||!$("#endDate").val()){
                   alert("please select a date");
                   return false;
                }
                //alert($('#selectedpte').val());
                //var t=$('#editForm');
                // t.attr('action','save');
                // alert(t.attr('action'));
				//$('#editForm').submit();
			};
			function doDelete(){
                if (!$('#selPlanId').val()){
                   alert("please select a Plan");
                   return false;
                }
                if (!confirm("are you sure to delete this plan")){
                    return false;
                }
                //alert($('#selectedpte').val());
                var t=$('#editForm');
                t.attr('action','delete');
               // alert(t.attr('action'));
				$('#editForm').submit();
			};
			function doSelectPlan(day,plan){
				$('#selPlanId').val(plan);
				$('#selDay').val(day);
				var t=$('#editForm');
                t.attr('action','select');
				$('#editForm').submit();
			};
			function doSelectDay(day){
				$('#selDay').val(day);
				$('#selPlanId').val("");
				var t=$('#editForm');
                t.attr('action','select');
				$('#editForm').submit();
			};
		    function goBack(){
			   location.href='<s:url value="/marketing/list"/>';
		    };
</script>
<s:head  />
	</head>
 	<body>
		<s:include value="/common/up.jsp"></s:include>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td class="box">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td id="tag-over">
								<span id="tag-over">Marketing Plan</span>
							</td>
							<td class="tab3-line" width="85%">
								&nbsp;
							</td>
						</tr>
					</table>
					<s:form action="save" namespace="/marketing" method="post"
						id="editForm" name="editForm">
				    <s:hidden  id="id" name="model.id"/>
					<s:hidden name="selPlanId" id="selPlanId"/> 
					<s:hidden name="selDay" id="selDay"/> 
					<table width="100%" border="0" cellpadding="3" cellspacing="1"
						bgcolor="#DCCFC0" class="margin">
						<tr>
							<td align="right" class="tablecolour5">
								Ad Channel:
							</td>
							<td class="tablecolour5" colspan='3'>
						 		<s:textfield id="selAdChannel" size="50" name="adChannelName" />
								<s:hidden id="selAdChannelId" name="selAdChannelId" />
							</td>
						</tr>	 
						<tr>
							<td align="right" bgcolor="#FFFFFF">
								Year:
								<s:select id="year" list="{2008,2009,2010,2011}" name="year">
								</s:select>
								Month:
								<s:select id="month" list="{1,2,3,4,5,6,7,8,9,10,11,12}"
									name="month">
								</s:select>
							</td>
							<td class="tablecolour5" bgcolor="#FFFFFF" colspan='3'>
								<table id="plantable" width="100%" border="0" cellpadding="0"
									cellspacing="2" bgcolor="#FFFFFF" class="margin">
									<tr>
										<th class="tablecolour5" align="center">
											Mon
										</th>
										<th class="tablecolour5" align="center">
 				                            Tue
										</th>
										<th class="tablecolour5" align="center">
											Wed
										</th>
										<th class="tablecolour5" align="center">
											Thu
										</th>
										<th class="tablecolour5" align="center">
											Fri
										</th>
										<th class="tablecolour5" align="center">
											Sat
										</th>
										<th class="tablecolour5" align="center">
											Sun
										</th>
									</tr>
									<s:property value="adChannelMonthPlan" escape="false" />
								 
								</table>
						    </td>
						</tr>
						<tr>
							<td align="right" class="tablecolour5">
								Name:
							</td>
							<td class="tablecolour5" colspan='3'>
								<s:textfield name="model.name" readonly="true"  cssClass="input2" size="40" />
								<s:radio name="model.state" listKey="name()" 
									list="@com.ef.constant.EMarketingPlanState@values()" />
							</td>
						</tr>
						<tr>
							<td align="right" class="tablecolour5">
								Start Date:
							</td>
							<td class="tablecolour5">
								<s:date name="model.startDate" format="yyyy-MM-dd" var="tstartDate" />
								<s:textfield value="%{#tstartDate}" name="model.startDate"
									id="startDate" />
							</td>
							<td align="right" class="tablecolour5">
								End Date:
							</td>
							<td class="tablecolour5">
								<s:date name="model.endDate" format="yyyy-MM-dd" var="tendDate" />
								<s:textfield value="%{#tendDate}" name="model.endDate" id="endDate" />
							</td>
						</tr>
						<tr>
							<td align="right" class="tablecolour5">
								Budget:
							</td>
							<td class="tablecolour5">
    				    	    <s:textfield name="model.budget"  id="description"   cssClass="input2 number" size="20" />
							</td>
							<td align="right" class="tablecolour5">
								Expense:
							</td>
							<td class="tablecolour5">
					            <s:textfield name="model.expense"  id="description"   cssClass="input2 number" size="20" />
							</td>
						</tr>
						<tr>
							<td align="right" class="tablecolour5">
								Target Leads Number:
							</td>
							<td class="tablecolour5">
    							  <s:textfield name="model.targetLeadNumber"  id="description"   cssClass="input2 number" size="20" />
							</td>
							<td align="right" class="tablecolour5">
								Leads Number:
							</td>
							<td class="tablecolour5">
    					    	  <s:textfield name="model.leadNumber"  id="description"   cssClass="input2 number" size="20" />
							</td>
						</tr>
						<tr>
							<td align="right" class="tablecolour5">
								Address:
							</td>
							<td class="tablecolour5" colspan='3'>
							   <s:textfield name="model.address"  id="description"   cssClass="input2" size="60" />
 							</td>
						</tr>
						<tr>
							<td align="right" class="tablecolour5">
								Description:
							</td>
							<td class="tablecolour5" colspan='3'>
							    <s:textfield name="model.description"  id="description"   cssClass="input2" size="60" />
							</td>
						</tr>
						<tr>
							<td align="center" colspan="4" bgcolor="#FFFFFF" height="50">
							    <!-- struts2 的控件 必须为submit -->
								<input type="submit"  class="btn1" value="Save"  
										onclick="return doSave();" />
								<input type="button" class="btn1" class="btn1" value="Go Back"
									onclick="goBack();" />
								<input type="button" class="btn1"class="btn1" value="Delete"
									onclick="doDelete();" />
							</td>
						</tr>
					</table>
					</s:form>
				</td>
			</tr>
		</table>
		<s:include value="/common/down.jsp"></s:include>
		<div id='pop-div' style="width: 300px;" class="pop-box">
			<s:include value="/common/confirm.jsp"></s:include>
		</div>
	</body>
</html>
